package com.chinanet.netelementmodel;
import com.chinanet.entry.netelement.Attr;
import com.chinanet.entry.netelement.AttrType;
import com.chinanet.entry.netelement.WorkInterFace;
import com.chinanet.utils.webservice.AttrsIn;
import com.chinanet.utils.webservice.WebService;

import java.util.HashMap;
import java.util.Map;


/**
 * IVPN_WebService_Imp_GetOnecardfortwo
 * IVPN一卡双号查询
 * @author xuzhi
 *
 */
public class IVPN_WebService_Imp_GetOnecardfortwo implements WorkInterFace {

	@Override
	public String getName() {
		return "IVPN一卡双号查询";
	}

	@Override
	public String getDesciption() {
		return "";
	}

	@Override
	public int getVersion() {
		return 0;
	}

	@Override
	public Attr[] getInAttrs() {
		Attr[] in=new Attr[1];
		in[0]=new Attr("mdn","mdn", AttrType.TYPE_String,true);
		return in;
	}

	@Override
	public Attr[] getOutAttrs() {
		Attr[] out = new Attr[12];
		out[0]=new Attr("ReturnCode", "0：成功；其它：失败", AttrType.TYPE_Int, true);
		out[1]=new Attr("Report", "返回report", AttrType.TYPE_String, true);
		out[2]=new Attr("手机号码", "手机号码", AttrType.TYPE_String, true);
		out[3]=new Attr("副号码", "副号码", AttrType.TYPE_String, true);
		out[4]=new Attr("付费类型", "付费类型", AttrType.TYPE_String, true);
		out[5]=new Attr("副号码地区编号", "副号码地区编号", AttrType.TYPE_String, true);
		out[6]=new Attr("用户状态", "用户状态", AttrType.TYPE_String, true);
		out[7]=new Attr("开户时间", "开户时间", AttrType.TYPE_String, true);
		out[8]=new Attr("结束时间", "结束时间 ", AttrType.TYPE_String, true);
		out[9]=new Attr("修改时间", "修改时间", AttrType.TYPE_String, true);
		out[10]=new Attr("log", "服务器返回的soapxml", AttrType.TYPE_String, true);
		out[11]=new Attr("Errormsg", "服务器返回的错误信息,当ReturnCode为0的时候就不必去读取", AttrType.TYPE_String, false);
		return out;
	}

	@Override
	public Map<String, Object> init(Map<String, Object> data) {
		AttrsIn attrsIn=new AttrsIn();
		WebService webService=new WebService();
		Map<String,Object> map=new HashMap<String, Object>();
		//Get into arguments
		attrsIn.setClientSysName("CDMA");
		attrsIn.setFunctionName("getOnecardfortwo");
		attrsIn.setRequestMessage("<MDN>"+(String) data.get("mdn")+"</MDN>");
		//Get soapxml
		String returnXml=webService.WebServiceInit(attrsIn);
		String flag=webService.getPattern("flag", returnXml);
		if(flag.equals("true")){
			map.put("ReturnCode", 0);
			map.put("Report", webService.getPattern("Report", returnXml));
			map.put("手机号码", webService.getPattern("手机号码", returnXml));
			map.put("副号码", webService.getPattern("副号码", returnXml));
			map.put("付费类型", webService.getPattern("付费类型", returnXml));
			map.put("副号码地区编号", webService.getPattern("副号码地区编号", returnXml));
			map.put("用户状态", webService.getPattern("用户状态", returnXml));
			map.put("开户时间", webService.getPattern("开户时间", returnXml));
			map.put("结束时间", webService.getPattern("结束时间", returnXml));
			map.put("修改时间", webService.getPattern("修改时间", returnXml));
			map.put("log", webService.dealkouhao(returnXml));
			map.put("Errormsg", "");
			map.put("flag",1);
		}else{
			map.put("flag",0);
			map.put("ReturnCode", 1);
			map.put("Report", "");
			map.put("手机号码", "");
			map.put("副号码","");
			map.put("付费类型", "");
			map.put("副号码地区编号", "");
			map.put("用户状态", "");
			map.put("开户时间","" );
			map.put("结束时间", "");
			map.put("修改时间", "");
			map.put("log", webService.dealkouhao(returnXml));
			map.put("Errormsg", "网元侧执行出错，处理请求失败");
		}
		
		return map;
	}

}
